package com.schoolcloud.serve.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.schoolcloud.common.model.PageDTO;
import com.schoolcloud.serve.entity.Sku;
import com.schoolcloud.serve.query.SkuQuery;
import com.schoolcloud.serve.service.SkuService;
import com.schoolcloud.serve.mapper.SkuMapper;
import com.schoolcolud.daomybatisplus.dto.MpPageUtil;
import org.springframework.stereotype.Service;

/**
* @author hongmizfb
* @description 针对表【sku】的数据库操作Service实现
* @createDate 2025-04-12 17:11:02
*/
@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku>
    implements SkuService{

    @Override
    public PageDTO<Sku> getSkuPage(SkuQuery skuQuery) {
        String categoryId = skuQuery.getCategoryId();
        String keyword = skuQuery.getKeyword();
        Page<Sku> page = lambdaQuery()
                .eq(StrUtil.isNotBlank(categoryId), Sku::getCategoryId, categoryId)
                .like(StrUtil.isNotBlank(keyword), Sku::getSkuName, keyword)
                .page(skuQuery.toMpPage());
        return MpPageUtil.of(page, Sku.class);
    }
}




